﻿using System.ComponentModel;
using System.Windows;

namespace WpfApp2
{
    internal class MainWindowDataContext : ObservableObject
    {
        private string _UserName;
        public bool IsSubmitAllowed => !string.IsNullOrWhiteSpace(UserName);

        public string UserName
        {
            get => _UserName;
            set
            {
                Set(ref _UserName, value);
                RaisePropertyChanged(nameof(IsSubmitAllowed));
                // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(UserName)));
            }
        }

        public Visibility GreetingVisibility => IsNameNeeded ? Visibility.Collapsed : Visibility.Visible;

        public MainWindowDataContext()
        {
        }

        public new event PropertyChangedEventHandler PropertyChanged;

        private bool _isNameNeeded = true;

        public bool IsNameNeeded
        {
            get { return _isNameNeeded; }
            set
            {
                if (Set(ref _isNameNeeded, value))
                {
                    RaisePropertyChanged(nameof(GreetingVisibility));
                }
            }
        }
    }
}